package com.zhoux.api.io.io;

import java.io.*;
import java.util.Scanner;

/**
 * @author taoyi
 * @version 1.0
 * @date 2021/3/29 14:16
 */
public class PW_Demo {
    public static void main(String[] args) {
        PrintWriter pw = null;
        Scanner in = new Scanner(System.in);
        try {
            pw = new PrintWriter(
                    new BufferedWriter(
                            new OutputStreamWriter(
                                    new FileOutputStream(".\\src\\main\\java\\com\\ty\\file\\pw.txt"),"utf-8"
                            )
                    ),true // true: 自动行刷新
            );
            while (true){
                String line = in.nextLine();
                //System.out.println("请输入要写入的数据或者输入 exit 退出:");
                if ("exit".equalsIgnoreCase(line))break;
                pw.println(line);
            }
        } catch (IOException e) {
            e.printStackTrace();
        }finally {
            pw.close();
        }
    }
}
